package com.ruoyi.smartcity.park.controller;

import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.smartcity.park.domain.ParkCheinfo;
import com.ruoyi.smartcity.park.service.IParkCheinfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 车辆信息Controller
 * 
 * @author ruoyi
 * @date 2025-02-27
 */
@RestController
@RequestMapping("/cheinfo")
public class ParkCheinfoController extends BaseController
{
    @Autowired
    private IParkCheinfoService parkCheinfoService;

    /**
     * 查询车辆信息列表
     */
    @GetMapping("/list")
    public TableDataInfo list(ParkCheinfo parkCheinfo)
    {
        startPage();
        List<ParkCheinfo> list = parkCheinfoService.selectParkCheinfoList(parkCheinfo);
        return getDataTable(list);
    }

    /**
     * 导出车辆信息列表
     */
    @Log(title = "车辆信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ParkCheinfo parkCheinfo)
    {
        List<ParkCheinfo> list = parkCheinfoService.selectParkCheinfoList(parkCheinfo);
        ExcelUtil<ParkCheinfo> util = new ExcelUtil<ParkCheinfo>(ParkCheinfo.class);
        util.exportExcel(response, list, "车辆信息数据");
    }

    /**
     * 获取车辆信息详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(parkCheinfoService.selectParkCheinfoById(id));
    }

    /**
     * 新增车辆信息
     */
    @Log(title = "车辆信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ParkCheinfo parkCheinfo)
    {
        return toAjax(parkCheinfoService.insertParkCheinfo(parkCheinfo));
    }

    /**
     * 修改车辆信息
     */
    @Log(title = "车辆信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ParkCheinfo parkCheinfo)
    {
        return toAjax(parkCheinfoService.updateParkCheinfo(parkCheinfo));
    }

    /**
     * 删除车辆信息
     */
    @Log(title = "车辆信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(parkCheinfoService.deleteParkCheinfoByIds(ids));
    }
}
